package com.ymttest.database.sqlwapper.godmch;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.model.mch_relation;
import com.ymttest.database.model.ymt_autoreply;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
/************************************************************************************
 * @File name : mch_relationWapperWapper.java
 * @Author : 吴文
 * @Date : 
 * @Copyright : 洋码头
 *godmach
 ************************************************************************************/
public class mch_relationWapper {
	SqlManager manage;
	public mch_relationWapper() {
		manage = new SqlManager("mysqlgodmchdb" + EnvSetup.getEnv());
		 
	}
	public  List<mch_relation> selectby(Map<String,Object> map) throws InterruptedException {
		
		List<mch_relation> list = manage.getSelectResults("com.ymttest.database.mapping.godmch.mch_relationMapper.selectby",map);
		manage.commit();
		return list;
	}
	
	public Integer selectCount(Map<String,Object> map) throws InterruptedException {
		
		Integer total = (int) manage.getSelectResults("com.ymttest.database.mapping.godmch.mch_relationMapper.selectCount",map).get(0);
		manage.commit();
		return total;
	}
	
	public  List<mch_relation> selectbyOrder(Map<String,Object> map) throws InterruptedException {
		
		List<mch_relation> list = manage.getSelectResults("com.ymttest.database.mapping.godmch.mch_relationMapper.selectbyOrder",map);
		manage.commit();
		return list;
	}
	
	public  List<mch_relation> selectByPrimaryKey(int mchId,int parentMchId) throws InterruptedException {
		HashMap<String,Object> map=new HashMap<String,Object>();
		map.put("mchId", mchId);
		map.put("parentMchId", parentMchId);
		List<mch_relation> list = manage.getSelectResults("com.ymttest.database.mapping.godmch.mch_relationMapper.selectByPrimaryKey",map);
		manage.commit();
		return list;
	}
	
	public void updateMchRelationToUnbind(int mchId) throws InterruptedException {
		HashMap<String,Object> map=new HashMap<String,Object>();
		
		map.put("createTime", YMTDateUtil.getBeforeOrNextHour(-2));
		map.put("parentMchId", mchId);
		List<mch_relation> list = manage.getSelectResults("com.ymttest.database.mapping.godmch.mch_relationMapper.updateMchRelationToUnbind",map);
		manage.commit();
	}
	
	public static void main(String[] args) throws InterruptedException {
		
		mch_relationWapper test = new mch_relationWapper();
		
		test.updateMchRelationToUnbind(500002490);
	}
}
